﻿namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
    using System;
    using System.Drawing;

    public static class TrayInfo
    {
        public static Hardcodet.Wpf.TaskbarNotification.Interop.Point GetTrayLocation()
        {
            AppBarInfo info = new AppBarInfo();
            info.GetSystemTaskBarPosition();
            Rectangle workArea = info.WorkArea;
            int right = 0;
            int bottom = 0;
            if (info.Edge == AppBarInfo.ScreenEdge.Left)
            {
                right = workArea.Left + 2;
                bottom = workArea.Bottom;
            }
            else if (info.Edge == AppBarInfo.ScreenEdge.Bottom)
            {
                right = workArea.Right;
                bottom = workArea.Bottom;
            }
            else if (info.Edge == AppBarInfo.ScreenEdge.Top)
            {
                right = workArea.Right;
                bottom = workArea.Top;
            }
            else if (info.Edge == AppBarInfo.ScreenEdge.Right)
            {
                right = workArea.Right;
                bottom = workArea.Bottom;
            }
            return new Hardcodet.Wpf.TaskbarNotification.Interop.Point { X = right, Y = bottom };
        }
    }
}

